<template>
    <el-dialog title="微信扫一扫" :visible="show" :modal-append-to-body="false" :close-on-click-modal="false" :before-close="closeDlg" center width="30%">
        <span id="print">
            <img :src="imgSrc" alt ref="equipment_id" class="photoClass" />
        </span>
        <span slot="footer" class="dialog-footer">
            <el-button type="success" @click.prevent="doPrint">打 印</el-button>
            <el-button type="success" @click="downLoadqr">下 载</el-button>
            <!-- <el-button type="primary"  @click="show">取 消</el-button> -->
        </span>
    </el-dialog>
</template>
<script>
    import wx from '../../../assets/image/wx.png'
    // import { getDtuTemplate, upload } from "@/service/basicSetting/index.js";
    export default {
        name: "newDtu",
        components: {},
        data() {
            return {
                show: false,
                imgSrc: wx,
                equipment_id: "",
            };
        },

        mounted() {},
        methods: {
            //打开弹窗
            showData() {
                this.show = true;
                this.imgSrc = wx;
                this.equipment_id = 'hello';

            },
            //关闭弹窗
            closeDlg() {
                this.show = false;
            },
            //下载
            downLoadqr() {
                var a = document.createElement("a");
                a.setAttribute("href", this.imgSrc);
                a.setAttribute("download", this.equipment_id + ".png");
                a.click();
            },
            //打印
            doPrint() {
                const subOutputRankPrint = document.getElementById('print')
                const newContent = subOutputRankPrint.innerHTML
                const oldContent = document.body.innerHTML
                document.body.innerHTML = newContent
                window.print()
                window.location.reload()
                document.body.innerHTML = oldContent
                return false
                console.log(newContent);
            }
        }

    };
</script>
<style lang="scss" scoped>
    /deep/.el-dialog--center .el-dialog__body {
        text-align: center;
    }

    .photoClass {
        width: 100%;
        height: 50%;

    }

    /deep/ .el-dialog__header {
        padding: 40px 40px 10px;
    }

    //打印
</style>